import {
  ModuleWithProviders, NgModule,
  Optional, SkipSelf }         from '@angular/core';
import { CommonModule } from '@angular/common';

import { Page404Module } from '../page-404/page-404.module';
import { AuthService } from '../auth/auth.service';
import { TranslateModule } from './translate.module';
import { I18nService } from './i18n.service';
import {ToasterModule, ToasterService} from 'angular2-toaster';
import { LoggedInGuard } from '../auth/loggedIn.guard';
import { UntreatedMessagesNumberService } from '../untreated-messages/untreated-messages-number.service';
import { LayoutMenuService } from '../layout-menu/layout-menu.service';
//import { Routes, RouterModule } from '@angular/router';
import { HttpModule }          from '@angular/http';
import { RecentlyDocumentsService } from '../recently-documents/recently-documents.service';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';

@NgModule({
  imports: [
    CommonModule,
    Page404Module,
    TranslateModule,
    ToasterModule,
    BsDropdownModule.forRoot(),
  ],
  declarations: [],
  exports: [
    ToasterModule,
    TranslateModule,
    HttpModule,
    //RouterModule,
    //NgxTranslateModule,
    BsDropdownModule,
  ],
  providers: [
    AuthService,
    I18nService,
    ToasterService,
    LoggedInGuard,
    UntreatedMessagesNumberService,
    LayoutMenuService,
    RecentlyDocumentsService,
  ]
})
export class CoreModule {
  constructor (@Optional() @SkipSelf() parentModule: CoreModule) {
    if (parentModule) {
      throw new Error(
        'CoreModule is already loaded. Import it in the AppModule only');
    }
  }
}
